package com.mdx.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mdx.bean.GalleryBean;
import com.mdx.service.IGalleryService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.time.LocalDate;

/**
 * 出库
 */
@RestController
@RequestMapping("gallery")
public class GalleryController {
    @Resource
    private IGalleryService galleryService;

    //查询所有
    @RequestMapping("findAll")
    public IPage<GalleryBean> findAll(@RequestParam(value = "pageNO", defaultValue = "1") int pageNO,
                                      @RequestParam(value = "pageSize", defaultValue = "2") int pageSize){
        return galleryService.showByItem(pageNO,pageSize,null,null,null);
    }

    //根据id查询
    @RequestMapping("findById")
    public GalleryBean findById(int galleryId){
        return galleryService.findById(galleryId);
    }

    //模糊查询
    @RequestMapping("findByItem")
    public IPage<GalleryBean> findByItem(@RequestParam(value = "pageNO", defaultValue = "1") int pageNO,
                                         @RequestParam(value = "pageSize", defaultValue = "2") int pageSize,
                                         String className, LocalDate start, LocalDate end){
        return galleryService.showByItem(pageNO,pageSize,className,start,end);
    }
}
